/*
 * CameraGameState.java
 *
 *  Copyright (c) 2008 Corey Oliver and Anshul Kumaria
 *
 *  This file is part of Balls of Fury.
 *
 *  Balls of Fury is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Balls of Fury is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 *
 */

/*
 * EDIT:  03/13/2008 - This is an example of how an edit performed to the class 
 * would appear.
 */

package ballsoffury.game;

import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.scene.CameraNode;
import com.jme.scene.Node;
import com.jme.system.DisplaySystem;
import com.jmex.game.state.BasicGameState;

/**
 * <code>CameraGameState</code> allows for management of the game. Various methods 
 * are included in this class to show various screens, alter preferences,  
 * and exit the application.
 *
 * @author Corey Oliver
 * @version $Revision:$ $Date:$
 */
public class CameraGameState extends BasicGameState {

    private Node cameraRotationNode;
    private Node cameraDistanceNode;
    private CameraController cameraController;
    
    public CameraGameState() {
        super("camera");
        initCamera();
    }

    private void initCamera() {
       Camera camera = DisplaySystem.getDisplaySystem().getRenderer().getCamera();
        cameraRotationNode = new Node("camRotation");
        cameraDistanceNode = new CameraNode("camDistance", camera);
        cameraDistanceNode.setLocalRotation(new Quaternion().fromAngleNormalAxis(FastMath.PI, new Vector3f(0, 1, 0)));
        cameraRotationNode.attachChild(cameraDistanceNode);
    
        rootNode.attachChild(cameraRotationNode);
        
        rootNode.addController(cameraController = new CameraController(this));
        rootNode.updateRenderState();
    }
    
    public Node getCameraRotationNode() {
        return cameraRotationNode;
    }

    public Node getCameraDistanceNode() {
        return cameraDistanceNode;
    } 
    
    public void setFixed() {
        cameraController.setActive(false);
        cameraDistanceNode.setLocalTranslation(new Vector3f(0, 0, 20.0f));
        cameraRotationNode.setLocalRotation(new Quaternion());

    }
    
    public void setMoveable() {
        cameraController.setActive(true);
    }
}